class Rater:
    def rateDisease(self, disease_list):
        # [{'name': '高血压', 'treatment_status': '1', 'status': '1'},
        # {'name': '糖尿病', 'treatment_status': '1', 'status': '1'},
        # {'name': '骨质疏松', 'treatment_status': '1', 'status': '1'},
        # {'name': '子宫肌瘤', 'treatment_status': '1', 'status': '1'},
        # {'name': '卵巢良性肿瘤', 'treatment_status': '0', 'status': '1'},
        # {'name': '乳腺良性肿瘤', 'treatment_status': '1', 'status': '1'},
        # {'name': '被动吸烟', 'status': '1'},
        # {'name': '吸烟', 'status': '1'}]
        # 1:是，0:否
        # 疾病权重
        weights = {
            "高血压": 8,
            "糖尿病": 6,
            "骨质疏松": 4,
            "子宫肌瘤": 4,
            "卵巢良性肿瘤": 4,
            "乳腺良性肿瘤": 4,
            "被动吸烟": 4,
            "吸烟": 8,
        }
        score = 100
        report = ""
        for item in disease_list:
            name = item.get("name", "").strip()
            weight = weights.get(name, -1)
            if weight > 0:
                score -= self.__score(item, weight)
        if score >= 90:
            report = f"健康评分：{score}分，身体很健康，继续保持良好生活习惯"
        elif score >= 80:
            report = f"健康评分：{score}分，身体有些许风险，建议注意作息和饮食"
        elif score >= 70:
            report = f"健康评分：{score}分，身体有风险，建议咨询医生"
        else:
            report = f"健康评分：{score}分，身体有较高风险，建议立即咨询医生"
        return report

    def __score(self, item, weight):
        score = 0
        status = int(item.get("status", 0))
        treatment_status = int(item.get("treatment_status", -1))
        if status == 1:  # 有该病史
            if treatment_status < 1:  # 有该病史，并且没有接受正规治疗
                score = weight
            else:  # 有该病史，接受正规治疗
                score = weight / 2
        else:  # 无该病史
            score = 0
        return score
